/** PatientInvoicePanel */
package client.ui.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;

import domain.appointment.Appointment;
import domain.records.DoctorsOrders;
import domain.records.MedicalService;

/**
 * @author jessienewman
 * @version $Revision: 1.0 $
 */
public class PatientInvoicePanel extends DefaultPanel{
	/**
	 * Field center.
	 */
	private JPanel center;

	/**
	 * Field c.
	 */
	private GridBagConstraints c;
	
	/**
	 * Constructor for PatientInvoicePanel.
	 */
	public PatientInvoicePanel() {
		center = new JPanel();
		add(center, BorderLayout.CENTER);
		center.setBackground(Color.WHITE);
		center.setLayout(new GridBagLayout());
		c = new GridBagConstraints();
	}
	
	/**
	 * Method updateAppointment.
	 * @param a Appointment
	 */
	public void updateAppointment(Appointment a) {
		if (a == null) {
			return;
		}
		c.gridx = 0;
		c.gridy = 0;
		c.gridwidth = 1;
		center.add(new JLabel("Name: "), c);
		c.gridx++;
		center.add(new JLabel(a.getPatient().getFullName()), c);
		c.gridy++;
		c.gridx = 0;
		center.add(new JLabel("Date: "), c);
		c.gridx++;
		center.add(new JLabel(a.getDateString()), c);
		c.gridx = 0;
		c.gridy++;
		center.add(new JLabel("Doctor: "), c);
		c.gridx++;
		center.add(new JLabel(a.getDoctor().getFullName()), c);
		c.gridy++;
		c.gridx = 0;
		center.add(new JLabel(" "));
		c.gridy++;
		center.add(new JLabel("SERVICES:"), c);
		c.gridy++;
		center.add(new JLabel("Service"), c);
		c.gridx++;
		center.add(new JLabel("Price"), c);
		c.gridy++;
		c.gridx = 0;
		DoctorsOrders dos = a.getTreatmentRecord().getOrders();
		if (dos.getService().size() == 0) {
			c.gridwidth = 2; // $codepro.audit.disable numericLiterals
			center.add(new JLabel("(No services were provided this visit.)"), c);
		} else {
			for (MedicalService s : a.getTreatmentRecord().getOrders().getService()) {
				c.gridx = 0;
				center.add(new JLabel(s.getServiceName()), c);
				c.gridx ++;
				Integer price = s.getPrice();
				center.add(new JLabel(price + ""), c);
			}
		}
	}
}
